package com.bwie.controller;
import com.bwie.pojo.Prod;
import com.bwie.pojo.ProdAtta;
import com.bwie.service.ProdService;
import com.bwie.service.impl.ProdServiceImpl;
import com.bwie.utils.R;
import com.bwie.vo.PageInfoVo;
import com.bwie.vo.ProdPageVo;
import io.swagger.annotations.ApiOperation;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import org.springframework.beans.factory.annotation.Autowired;

import java.util.List;

/**
* 商品表(tb_prod)表控制层
*
* @author xxxxx
*/
@RestController
@RequestMapping("/shop/prod")
public class ProdController {
/**
* 服务对象
*/
    @Autowired
    private ProdService prodService;

    @ApiOperation("prod列表")
    @PostMapping("/getProdList")
    public R getProdList(@RequestBody ProdPageVo prodPageVo){
        return prodService.getProdList(prodPageVo);
    }

    @ApiOperation("prod添加")
    @PostMapping("/addProdList")
    public R addProdList(@RequestBody @Validated Prod prod){
        return prodService.addProdList(prod);
    }

    @ApiOperation("添加商品附件")
    @PostMapping("/addProdAtta")
    public R addProdAtta(@RequestBody ProdAtta prodAtta){
        return prodService.addProdAtta(prodAtta);
    }

    @ApiOperation("批量删除")
    @PostMapping("/BatchDelete")
    public R BatchDelete(@RequestBody List<Integer> prodIds){
        return prodService.BatchDelete(prodIds);
    }

    @ApiOperation("单删除")
    @PostMapping("/deleteProd/{prodId}")
    public R deleteProd(@PathVariable Integer prodId){
        return prodService.deleteProd(prodId);
    }

    @ApiOperation("prodInfoList列表")
    @PostMapping("/prodInfoList")
    public R prodInfoList(){
        return prodService.prodInfoList();
    }

    @ApiOperation("Es商品表")
    @PostMapping("/getEsshoppingList")
    public R getEsshoppingList(@RequestBody ProdPageVo prodPageVo){
        return prodService.getEsshoppingList(prodPageVo);
    }

    @ApiOperation("创建索引")
    @GetMapping("/createIndex")
    public void createIndex(){
        prodService.createIndex();
    }

}
